
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"
struct File{
    char type;
    std::string content;
    File(char type,std::string& content):
        type(type),content(content){

    }
    File(){}
};
class OneLoop {
public:
    std::unordered_map<std::string,File> rec;
    void open(File& f){
        if(f.type=='0'){
            std::cout<<f.content<<std::endl;
        }else{
            open(rec[f.content]);
        }
    }
    void run(
           std::string &s
    ) {
        if(s.find("create")!=-1){
            int i1=7;
            int i2=8;
            while(s[i2]!=' '){
                i2++;
            }
            int i3=i2+1;
            while (s[i3]!=' '){
                i3++;
            }

            auto s1=s.substr(i1,i2-i1);
            auto s2=s.substr(i2+1,i3-i2-1);
            auto s3=s.substr(i3+1);
            ;
            rec[s1]=File(s2[0],s3);
        }
        if(s.find("open")!=-1){
            auto&file=rec[s.substr(5)];
            open(file);
        }
    }
};

class Solution {
public:
    void run() {

        bool first = true;
        int a, b, c, d, e;
        std::string s1, s2;
        OneLoop loop;

        while (
                std::getline(std::cin,s1)
                ) {
            if(s1=="exit"){
                return;
            }
//            std::getline(std::cin,s2);
//            auto cc=std::cin.get();//换行

            loop.run(s1);
        }

    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

